<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // localStorage作用
        // 可以将数据永久储存在本地（用户电脑）除非手动删除 关闭页面也会存在

        //存储数据localStorage.getItem(key,value)
        localStorage.setItem('sex', '男')
        //获取数据localStorage.getItem(key)
        let getitem = localStorage.getItem('sex')
        console.log(getitem)
        //删除数据localStorage.removeItem(key)
        // localStorage.removeItem('sex')
        //改
        localStorage.setItem('sex', '女')


        localStorage.setItem('age', 18)
        console.log(localStorage.getItem('age'));

    </script>
</body>

</html>